Skip to main content

rename

Type​

command

Summary​

Gives a file or folder a new name or moves it to a new location or both.

Syntax​

rename [{file | folder | directory}] <filePath> to <newPath>

Description​

Use the rename command to change the name or location of a file or folder.

The rename command can be used to change a file's or folder's location only if the old and new locations are both on the same volume.

warning

This command can be used to rename or move files and folders your stack did not create. Of course, a stack should not rename or move files and folders it didn't create without obtaining explicit confirmation from the user.

warning

If a file with the same file path as the newPath already exists, that file will be overwritten without confirmation.

Cross-platform note

On Windows, if a file with the same file path as newPath already exists then the rename operation will fail. On other platforms, the existing file may be overwritten. If the operation does fail, then the result will be "can't rename file". Note that a rename operation may fail on any operating system, so it's important to check the result afterwards.

Parameters​

NameTypeDescription

filePath

The filePath specifies the current name and location of the file or folder you want to rename or move. If you specify a name but not a location, LiveCode assumes the file or folder is in the defaultFolder.

newPath

The newPath specifies the new name and location of the file or folder.

Examples​

rename file "Foo.txt" to "Bar.txt"
rename folder "/bin/utilities/help" to "/public/utilities/new-help"

command: revCopyFile, create alias

function: tempName, files, folders

glossary: command, file, folder

keyword: file

object: stack

property: fileType

Compatibility and Support​

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?